﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sustainalytics.ClientDW.Entities;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.GCCS.Tests
{
    [TestClass]
    public class GCPrincipleSummaryManagerTests
    {
        [TestMethod]
        public void GetList_Success()
        {
            var expectedValue = new List<GCPrincipleSummary>
            {
                new GCPrincipleSummary { Id = Guid.NewGuid() },
                new GCPrincipleSummary { Id = Guid.NewGuid() },
                new GCPrincipleSummary { Id = Guid.NewGuid() }
            };

            var repo = new Sustainalytics.ClientDW.DataAccessLayer.Fakes.StubIClientDWGlobalCompactRepository
            {
                GetGCPrincipleSummaryListGuidNullableOfGCAssessment = (Guid companyId, GCAssessment? overallAssessment) =>
                    {
                        return expectedValue;
                    }
            };

            var manager = new GCPrincipleSummaryManager(repo);

            var value = manager.GetList(Guid.NewGuid(), null);

            Assert.IsNotNull(value, "Returned value is not null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than the expected.");
        }

        [TestMethod]
        public void GetList_Empty_Success()
        {
            var repo = new Sustainalytics.ClientDW.DataAccessLayer.Fakes.StubIClientDWGlobalCompactRepository
            {
                GetGCPrincipleSummaryListGuidNullableOfGCAssessment = (Guid companyId, GCAssessment? overallAssessment) =>
                {
                    return new List<GCPrincipleSummary>();
                }
            };

            var manager = new GCPrincipleSummaryManager(repo);

            var value = manager.GetList(Guid.NewGuid(), null);

            Assert.IsNotNull(value, "Returned value is not null.");
            Assert.IsTrue(value.Count == 0, "Returned value is different than the expected.");
        }
    }
}
